<?php
class Review_model extends CI_Model{
	
	function __construct() {
        parent::__construct();
    }
    
    public function get_seller_review_number($seller_id){
    	$sql = "SELECT COUNT(review_id) AS seller_review_number FROM review WHERE review_type = 1 AND object_id = {$seller_id}";
    	$query = $this->db->query($sql);
    	if ($query->num_rows > 0){
    		return $query->row()->seller_review_number;
    	}else{
    		return FALSE;
    	}
    }
    
	public function get_product_review_number($product_id){
    	$sql = "SELECT COUNT(review_id) AS product_review_number FROM review WHERE review_type = 0 AND object_id = {$product_id}";
    	$query = $this->db->query($sql);
    	if ($query->num_rows > 0){
    		return $query->row()->product_review_number;
    	}else{
    		return FALSE;
    	}
    }
    
    public function get_seller_review($seller_id, $offset, $limit){
    	$sql = "SELECT * FROM review WHERE review_type = 1 AND object_id = {$seller_id} LIMIT {$offset},{$limit}";
    	$query = $this->db->query($sql);
    	if ($query->num_rows > 0){
    		return $query->result_array();
    	}else{
    		return FALSE;
    	}
    }
}

/* End of file review_model.php */
/* Location: ./application/models/review_model.php */